<?php
/**
 * 公用Model基类
 */
class BaseViewModel extends ViewModel{
	
	/**
	 * 通过条件获取一条数据
	 * @param array $condition
	 * @param string $field
	 * @param string $order
	 * @param string $group
	 * @param integer $limit
	 * @return array
	 */
	public function getInfo($condition, $field, $order , $group , $limit){
		if($condition){
			$result = $this->where($condition)->field($field)->order($order)->group($group)->limit($limit)->find();
		}
		return $result;
	}
	
	/**
	 * 通过条件获取多条数据
	 * @param array $condition
	 * @param string $field
	 * @param string $order
	 * @param string $group
	 * @param integer $limit
	 * @return array
	 */
	public function getList($condition, $field, $order , $group , $limit){
		if($condition){
			$result = $this->where($condition)->field($field)->order($order)->group($group)->limit($limit)->select();
		}
		return $result;
	}
	
	/**
	 * 通过条件统计数量
	 * @param array $condition
	 * @return string
	 */
	public function getCount($condition){
		if($condition){
			$result = $this->where($condition)->count();
		}
		return $result;
	}

	
	/**
	 * 通过条件查询字段
	 * @param array $condition
	 * @param string $field
	 * @param string $isGetArray
	 * @return string
	 */
	public function getFieldByCondition($condition, $field, $isGetArray = false){
		if($field){
			$result = $this->where($condition)->getField($field, $isGetArray);
		}
		return $result;
	}
}